"""
    正则表达式
    贪婪匹配.*（尽可能匹配多的字符）
    非贪婪匹配.*?(推荐使用，避免出现匹配结果缺失的情况)
"""

import re

# findall方法会从字符串中匹配所有符合条件的字符串
content = '15101198106,13161688890,13051950060,13310881211'
result_findall = re.findall(r'1[35][^3]\d{8}',content)
print(f'result_findall type: {type(result_findall)}')
print(result_findall)
print('====================================================================')

# search方法会从输入字符串content中查找符合条件的字符串
result_search = re.search(r'13[13]+\d{8}',content)
print(f'result_search type: {type(result_search)}')
print(result_search.group())
print(result_search.span())
print('====================================================================')

result_match = re.match(r'13[01]\d{8}',content)
print(f'result_match type: {type(result_match)}')
if None != result_match:
    print(result_match)
    print(result_match.group())
    print(result_match.span())
print('====================================================================')

# sub方法将输入字符串content中的所有数字替换为pc
result_sub = re.sub(r'13[01]\d{8}','pc', content)
print(f'result_sub type: {type(result_sub)}')
if None != result_sub:
    print(result_sub)
print('====================================================================')